import request from '@/utils/request'


export function getAnnouncementList(pageNum,pageSize) {
  return request({
    url: `/announcement/announcementsGetAll/${pageNum}/${pageSize}`,
    method: 'get',
  })
}

export function announcementsGetId(id) {
  return request({
    url: `/announcement/announcementsGetId/${id}`,
    method: 'get',
  })
}

export function getUserAll() {
  return request({
    url: `/announcement/getUserAll`,
    method: 'get',
  })
}

export function handleDelete(announcementID) {
  return request({
    url: `/announcement/announcementsDelete/${announcementID}`,
    method: 'delete',
  })
}

export function submitForm(addAnnouncementList) {
  console.log(addAnnouncementList)
  return request({
    url: `/announcement/announcementsAdd`,
    method: 'Post',
    data:addAnnouncementList
  })
}

export function updateForm(updateAnnouncementList) {
  console.log(updateAnnouncementList)
  return request({
    url: `/announcement/announcementsUpdate`,
    method: 'PUT',
    data:updateAnnouncementList
  })
}



// 解决ERROR ResizeObserver loop completed with undelivered notifications.
// 重写ResizeObserver的构造函数，并在其中定义并调用防抖函数
window.ResizeObserver = class ResizeObserver extends window.ResizeObserver {
  constructor(callback) {
    let timer = null;
    const debouncedCallback = function () {
      let context = this;
      let args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function () {
        callback.apply(context, args);
      }, 16);
    };
    super(debouncedCallback);
  }
};
